package com.itrus.cryptorole.bc;

import com.itrus.cryptorole.CryptoException;
import com.itrus.cryptorole.WindowsCertStore;
import java.security.Principal;
import java.security.Provider;
import java.security.cert.X509Certificate;
import org.bouncycastle.jce.PKCS7SignedData;

public class SenderSunMSCAPIImpl extends SenderBcImpl
{
  private WindowsCertStore windowsCertStore;

  public SenderSunMSCAPIImpl(WindowsCertStore paramWindowsCertStore)
  {
    this.windowsCertStore = paramWindowsCertStore;
  }

  public void initCertWithKey(X509Certificate paramX509Certificate)
    throws CryptoException
  {
    this.certOfSigner = paramX509Certificate;
    try
    {
      this.keyOfSigner = this.windowsCertStore.getPrivateKey(paramX509Certificate);
      if (this.keyOfSigner == null)
        throw new CryptoException("指定的证书[" + paramX509Certificate.getSubjectDN().toString() + "]没有私钥。");
    }
    catch (Exception localException)
    {
      throw new CryptoException(localException);
    }
  }

  public byte[] signMessage(byte[] paramArrayOfByte)
    throws CryptoException
  {
    if ((this.keyOfSigner == null) || (this.certOfSigner == null))
      throw new CryptoException(this.notInitializeKeyMessage);
    X509Certificate[] arrayOfX509Certificate = new X509Certificate[1];
    arrayOfX509Certificate[0] = this.certOfSigner;
    try
    {
      PKCS7SignedData localPKCS7SignedData = new PKCS7SignedData(this.keyOfSigner, arrayOfX509Certificate, this.signAlgorithm.substring(0, this.signAlgorithm.indexOf("With")), this.windowsCertStore.getProvider().getName());
      localPKCS7SignedData.update(paramArrayOfByte, 0, paramArrayOfByte.length);
      byte[] arrayOfByte = localPKCS7SignedData.getEncoded();
      return arrayOfByte;
    }
    catch (Exception localException)
    {
      throw new CryptoException(localException);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.itrus.cryptorole.bc.SenderSunMSCAPIImpl
 * JD-Core Version:    0.6.2
 */